PHP: Building A Stock Index Using Yahoo Finance [on hold]
Posted
by
Jeremy
on Stack Overflow
See other posts from Stack Overflow
or by Jeremy
Published on 2014-06-11T03:03:47Z
Indexed on
2014/06/12
3:26 UTC
Read the original article
Hit count: 171
I have the following code which is pulling data but it is not outputting properly.
<?php
class YahooStock {
public function getQuotes(){
$stocks = array();
$result = array();
$s = file_get_contents("http://finance.yahoo.com/d/quotes.csv?s=AMZN+CRM+CNQR+CTL+CTXS+DWRE+EMC+GOOG+HP+IBM+JIVE+LNKD+MKTO+MSFT+N+NFLX+NOW+ORCL+RAX+SAP+T+VEEV+VMW+VZ+WDAY&f=npf6&e=.csv");
$data = explode( ',', $s);
$result = $data;
return $result;
}
}
$objYahooStock = new YahooStock;
foreach( $objYahooStock->getQuotes() as $code => $result){
echo 'Name:' . $result[0] . '<br />';
echo 'Price:' . $result[1] . '<br />';
echo 'Float:' . $result[2] . '<br />';
}
?>
The output looks like it is separating every character with a comma instead of each column: Name:" Price:A Float:m Name: Price:I Float:n Name:3 Price:3 Float:2 Name: Price: Float:
Any help is appreciated!
© Stack Overflow or respective owner